function polling() {
  console.log("polling");
  setTimeout(polling, 1000 * 3);

  //   chrome.tabs.query({active: true, currentWindow: true}, function(tabs) {
  //     chrome.tabs.sendMessage(
  //         tabs[0].id,
  //         {log: 'hello from background'},
  //         function(msg) {
  //           console.log(
  //               'result message:',
  //               msg,
  //           );
  //         },
  //     );
  //   });
  chrome.tabs.query({ active: true, currentWindow: true }, function(tabs) {
    // console.log('on query tabs callback');
    // console.log(`tabs = ${tabs.length}`);
    if (tabs.length > 0) {
      sendMsg(tabs[0], "你好");
    }
  });
}

function sendMsg(tab: chrome.tabs.Tab, msg: string) {
  chrome.tabs.sendMessage(tab.id, { log: msg });
  chrome.tabs.sendMessage(tab.id, { type: "csdn", subType: "readMore" });
}

polling();
